package com.jlf.controller.engine.entity.index;

import com.jlf.core.engine.domain.SchemaIndexDO;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;

/**
 * 文件注释
 *
 * @author wujr
 * 2023/7/18
 * @version 1.0
 * 【变更历史】
 * [wujr 2023/7/18 1.0 新增]
 */
@Getter
@Setter
public class IndexDetail {
    private Long id;
    private String name;
    private List<String> columns;
    /**
     * 是否唯一性
     */
    private Boolean uniqueness;
    /**
     * 索引类型：{@link com.jlf.core.engine.constant.SchemaConstant.Domain.Index}
     * type=1为索引
     * type=2为唯一键
     */
    private Integer type;
    /**
     * 索引的状态
     */
    private Integer status;
    private Integer priority;
    private String remark;

    public IndexDetail(SchemaIndexDO record) {
        this.id = record.getId();
        this.name = record.getName();
        this.columns = Arrays.asList(StringUtils.split(record.getColumns(), ","));
        this.uniqueness = record.getUniqueness();
        this.type = record.getType();
        this.status = record.getStatus();
        this.priority = record.getPriority();
        this.remark = record.getRemark();
    }
}
